package com.luoshi.common.exception;

import com.luoshi.common.exception.ucenter.MobileExistException;
import com.luoshi.common.exception.ucenter.MobileIsDisabledException;
import com.luoshi.common.exception.ucenter.MobileOrPasswordException;
import com.luoshi.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName GlobalExceptionHandler
 * @Description:统一异常处理器
 * @Author luochangqin
 * @Date 2021/5/16
 * @Version V1.0
 **/
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
    @ExceptionHandler(MobileOrPasswordException.class)
    public Result error(MobileOrPasswordException e){
        e.printStackTrace();
        return Result.error(e.getCode(),e.getMessage());
    }
    @ExceptionHandler(MobileExistException.class)
    public Result error(MobileExistException e){
        e.printStackTrace();
        return  Result.error(e.getCode(),e.getMessage());
    }
    @ExceptionHandler(MobileIsDisabledException.class)
    public Result error(MobileIsDisabledException e){
        e.printStackTrace();
        return  Result.error(e.getCode(),e.getMessage());
    }
}
